package com.hss.transition;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.transition.Fade;
import android.transition.Slide;
import android.transition.Transition;
import android.transition.TransitionInflater;
import android.transition.Visibility;
import android.view.Gravity;

import com.hss.recyclerviewtest.R;

public class ShareDetailActivity extends AppCompatActivity {
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_share_elements);

//API>=21
//        getWindow().setEnterTransition(buildEnterTransitionByCode());

        //再次进入时使用
//        getWindow().setReenterTransition(buildEnterTransitionByCode());

//        Visibility returnTransition = buildReturnTransition();
//        getWindow().setReturnTransition(returnTransition);

/*
* style
* <item name="android:windowEnterTransition">@android:transition/slide_left</item>
* <item name="android:windowExitTransition">@android:transition/slide_right</item>
* */
    }
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private Visibility buildReturnTransition() {
        Visibility enterTransition = new Slide();
        enterTransition.setDuration(500);
        return enterTransition;
    }
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private Transition buildEnterTransitionByCode() {
        Slide enterTransition = new Slide();
        enterTransition.setDuration(500);
        enterTransition.setSlideEdge(Gravity.RIGHT);
        Transition slide_top = TransitionInflater.from(this).inflateTransition(android.R.transition.slide_top);
        Fade fade = new Fade();
        return enterTransition;

//        Explode enterTransition = new Explode();
//        enterTransition.setDuration(500);
//        return enterTransition;
    }

}
